package com.jida.tijian.service;

import com.jida.tijian.domain.Doctor;
import com.jida.tijian.dto.ResponseObject;
import com.jida.tijian.mapper.DoctorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoctorServiceImpl implements DoctorService {
    //连接数据库Mapper
    @Autowired
    DoctorMapper doctorMapper;

    @Override
    public ResponseObject login(Doctor doctor){
//        doctorMapper.selectByDocCode(doctor.getDocCode());
       Doctor docCodeResult = doctorMapper.selectByDocCode(doctor.getDocCode());
        if(docCodeResult == null){
            System.out.println("账号错误");
            return new ResponseObject(3001,"您的账号输入错误，该账号尚未注册");
        }else if(!docCodeResult.getPassword().equals(doctor.getPassword())) {
//            密码校验
            System.out.println("密码错误" + docCodeResult.getPassword().equals(doctor.getPassword()));
        return new ResponseObject(3002,"您的密码输入错误");
        }

        return new ResponseObject(
                3000,
                "成功",
                doctorMapper.selectByDocCode(doctor.getDocCode())
        );
    }
}
